#pragma once
/* Copyright (C) 2009 Vlad Roubtsov. All rights reserved. */

#include <vector>
using std::vector;

#include <boost/variant.hpp>

#include "vr/deject/component.hpp"
#include "vr/deject/types.hpp"
#include "vr/deject/factory/value.hpp"
#include "vr/util/utility.hpp"

//----------------------------------------------------------------------------
namespace vr
{
namespace deject
{

class dependency_desc // copyable
{
    public: // ...............................................................

        typedef vector<component_id_type> seq_of_dep_id_type; // don't use lists for extra mem locality

        const dep_value_type::enum_t m_type;


        dependency_desc (const component_id_type & ID) :
            m_type (dep_value_type::REFERENCE),
            m_content (ID)
        {
        }

        dependency_desc (const seq_of_dep_id_type & IDs) :
            m_type (dep_value_type::SEQ_OF_REFERENCE),
            m_content (IDs)
        {
        }

        dependency_desc (const factory::value & v) :
            m_type (dep_value_type::VALUE),
            m_content (v)
        {
        }

        dependency_desc (const factory::value::map_of_val_type & vs) :
            m_type (dep_value_type::MAP_OF_VALUE),
            m_content (vs)
        {
        }


        operator const component_id_type & () const
        {
            return boost::get<const component_id_type> (m_content);
        }

        operator const seq_of_dep_id_type & () const
        {
            return boost::get<const seq_of_dep_id_type> (m_content);
        }

        operator const factory::value & () const
        {
            return boost::get<const factory::value> (m_content);
        }

        operator const factory::value::map_of_val_type & () const
        {
            return boost::get<const factory::value::map_of_val_type> (m_content);
        }


    private: // ..............................................................


        typedef boost::variant
            <
                seq_of_dep_id_type,
                component_id_type,
                factory::value::map_of_val_type,
                factory::value
            >
        allowed_dep_types;


        const allowed_dep_types m_content;

}; // end of class

} // end of 'container'
} // end of namespace
//----------------------------------------------------------------------------
